<template>
  <el-dialog :title="$t('query.event.upgradeInfo')" width="35%" :visible.sync="upgradeInfoVisible">
    <el-row>
      <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.upgradeData.upgradeType')}}</div></el-col>
      <el-col :span="12"><div class="grid-content" v-text="otaUpgradeTypeFormat(upgradeData.upgradeType)"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.upgradeData.upgradeStatus')}}</div></el-col>
      <el-col :span="12"><div class="grid-content" v-text="otaUpgradeFormat(upgradeData.upgradeStatus)"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.upgradeData.upgradeProgressTotal')}}</div></el-col>
      <el-col :span="12"><div class="grid-content" v-text="upgradeData.upgradeProgressTotal"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.upgradeData.upgradeProgressCur')}}</div></el-col>
      <el-col :span="12"><div class="grid-content" v-text="upgradeData.upgradeProgressCur"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.upgradeData.upgradeFileSize')}}</div></el-col>
      <el-col :span="12"><div class="grid-content" v-text="upgradeData.upgradeFileSize"></div></el-col>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
  name: 'upgrade',
  data() {
    return {
      upgradeData: {
        upgradeType: null,
        upgradeStatus: null,
        upgradeProgressTotal: null,
        upgradeProgressCur: null,
        upgradeFileSize: null,
      },
      upgradeInfoVisible: false,
    }
  },

  methods: {
    init(data) {
      this.upgradeData = data
      this.upgradeInfoVisible = true
    },

    otaUpgradeTypeFormat(data) {
      switch (data) {
        case 0:
          return this.$t('query.event.upgradeData.model')
        case 1:
          return this.$t('query.event.upgradeData.mcu')
        default:
          return data
      }
    },
    otaUpgradeFormat(data) {
      switch (data) {
        case 0:
          return this.$t('query.event.upgradeData.success')
        case 1:
          return this.$t('query.event.upgradeData.fail')
        case 2:
          return this.$t('query.event.upgradeData.upgrading')
        case 3:
          return this.$t('query.event.upgradeData.check')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.dialog-left-text {
  padding-left: 50px;
  font-weight: bold;
  font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
}
</style>
